home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload Trio 2 / Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO / dir26 / epi601_2.zip / FILES07.EXE / RSAMPLE.PGM < prev    next >
Text File  |  1994-08-22  |  2KB  |  53 lines

  1. *RSAMPLE.PGM, is a program to take a random sample of
  2. *records in a file.  If you want to take a 1/5 sample
  3. *of 75 records, for example, the sample will contain approximately
  4. *15 records.  A different sample is taken each time the program runs.
  5. *Note, however that the number of records in a sample may vary widely
  6. *and should be monitored.
  7.  
  8. READ ?   Name of .rec file to sample ?
  9. DEFINE DENOM #### GLOBAL
  10. DEFINE RANNUM ####
  11.  
  12. CLS
  13. ECHO
  14. ECHO
  15. ECHO This program takes a random sample of records in a file. The
  16. ECHO size of the sample may vary, especially when sampling small
  17. ECHO numbers of records, and you may wish to specify a smaller
  18. ECHO denominator for the sampling fraction than is actually desired
  19. ECHO in order to obtain a large enough sample.  When sampling from
  20. ECHO large numbers of records, the random process should produce a
  21. ECHO sample very close to the size expected.
  22. ECHO
  23. ECHO Please specify a denominator for the sampling fraction.
  24. ECHO To select 1 record out of 20 (a 5% sample), for example,
  25. ECHO you should enter 20 as the denominator...
  26. ECHO
  27. ECHO    Denominator of sampling fraction:
  28. ECHO    (Smaller numbers give larger samples)
  29. IMMEDIATE DENOM = ?    Must be an integer (e.g., 3,5,10,20): ?
  30. ECHO
  31. ECHO
  32. *Pick a random integer between 0 and the denominator
  33. RANNUM = RAN (DENOM)
  34. *If the number chosen happens to equal the denominator, select
  35. *the record.  On the average, this should happen 1/DENOM of the
  36. *time, giving the desired sample size in a random way.
  37. SELECT RANNUM = DENOM
  38. *Open output file
  39. ERASE RSAMPLE.REC
  40. ROUTE RSAMPLE.REC
  41. WRITE RECFILE NOT DENOM RANNUM
  42. *View results
  43. READ RSAMPLE.REC
  44. LIST
  45. TYPE "  The records above are contained in file RSAMPLE.REC."
  46. TYPE "  If you wish to save the sample, please rename or copy "
  47. TYPE "  RSAMPLE.REC before running RSAMPLE.PGM again."
  48. ? Press any key to QUIT ?
  49. QUIT
  50.  
  51.  
  52.  
  53.